package cn.com.rexen.rplus.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

import java.util.Iterator;
import java.util.Map;

/**
 * 首页controller.
 * 
 * @author libo <br/>
 *         date:2014-04-22
 * @version 1.0.0
 */
@Controller
public class MainController {

    @Autowired
    RequestMappingHandlerMapping handlerMapping;
    /**
     * 重新加载权限.
     * 
     * @return ModelAndView.
     */
    @RequestMapping(value = "/reload")
    public ModelAndView reloadPermission() {

        Map map =  this.handlerMapping.getHandlerMethods();
        Iterator<?> iterator = map.entrySet().iterator();
        while(iterator.hasNext()) {
            Map.Entry entry = (Map.Entry) iterator.next();
            System.out.println(entry.getKey() + "\n" + entry.getValue());
        }
        ModelAndView mv = new ModelAndView();
        return mv;
    }

    //@RequestMapping(value = "/resources/config", method = RequestMethod.GET, produces = "application/javascript")
    /**
     * js配置.
     * 
     * @return ModelAndView.
     */
    public ModelAndView inJs() {
        ModelAndView mav = new ModelAndView("/config");
        return mav;
    }

    /**
     * 首页 跳转.
     * 
     * @return ModelAndView.
     */
    @RequestMapping(value = "/main", method = RequestMethod.GET)
    public ModelAndView index() {
        ModelAndView mav = new ModelAndView("/sa/index");
        return mav;
    }
}
